package com.leemz.tgs.common;


import lombok.Data;

import java.io.Serializable;

@Data
public class JsonResult<T> implements Serializable {

    public static final String SUCCESS_MSG = "成功";
    public static final Integer SUCCESS_CODE = 0;

    private Integer code;
    private String msg;
    private Long count;
    private T data;

    /**
     * 返回成功的结果, code默认为0
     * @return
     */
    public JsonResult pageSuccess(T data, Long count) {
        JsonResult pageResult = new JsonResult();
        pageResult.data = data;
        pageResult.code = SUCCESS_CODE;
        pageResult.count = count;
        pageResult.msg = SUCCESS_MSG;
        return pageResult;
    }

    public JsonResult success(T data) {
        JsonResult pageResult = new JsonResult();
        pageResult.data = data;
        pageResult.code = SUCCESS_CODE;
        pageResult.msg = SUCCESS_MSG;
        return pageResult;
    }
}
